package com.example.logisticsingle.utils;


import com.example.logisticsingle.constants.ResponseEnum;
import com.example.logisticsingle.dto.Result;

/**
 * Result工具类

 *
 */
public class ResultUtils {
	/**
	 * 创建成功结果集
	 * @param date
	 * @return
	 */
	public static <T> Result<T> sucess(T data){
		Result<T> result = new Result<>(ResponseEnum.SUCCESS, true, data);
		return result;
	}
	/**
	 * 创建成功结果集
	 * @param responseEnum
	 * @param date
	 * @return
	 */
	public static <T> Result<T> sucess(ResponseEnum responseEnum,T data){
		Result<T> result = new Result<>(responseEnum, true, data);
		return result;
	}
	/**
	 * 成功响应结果
	 * @param responseEnum
	 * @return
	 */
	public static <T> Result<T> sucess(ResponseEnum responseEnum){
		Result<T> result = new Result<>(responseEnum, true);
		return result;
	}
	
	/**
	 * 创建错误信息
	 * @param responseEnum
	 * @return
	 */
	public static  Result<?> failure(ResponseEnum responseEnum){
		return new Result<>(responseEnum,false);
	}
	/**
	 * 失败结果
	 * @param responseEnum
	 * @param date
	 * @return
	 */
	public static  <T> Result<T> failure(ResponseEnum responseEnum,T data){
		return new Result<T>(responseEnum,false,data);
	}
	/**
	 * 失败信息
	 * @param code
	 * @param message
	 * @return
	 */
	public static  Result<?> failure(String code,String message){
		return new Result<>(code,message,false);
	}
	/**
	 * 
	 * @param <T>
	 * @param code
	 * @param message
	 * @param date
	 * @return
	 */
	public static  <T> Result<T> failure(String code,String message,T data){
		return new Result<T>(false, code, message, data);
	}
}
